import React, { Component } from 'react';
import {renderRoutes} from 'react-router-config';
import {connect} from 'dva';
import { Layout } from 'antd';
import MenuList from './menulist';

const { Header, Content, Sider } = Layout;

class Main extends Component {
    
    componentDidMount() {
        console.log(this.props)
        //获取个人信息和视图权限
        this.props.dispatch({
            type:'user/GET_USERINFO'
        })
    }
    
    render() {
        console.log(this.props)
        return (
            <Layout>
                <Header className="header">
                    <div className="logo" />
                </Header>
                <Layout>
                    <Sider width={200} className="site-layout-background">
                        {/* z左侧菜单 */}
                        <MenuList></MenuList>
                    </Sider>
                    <Layout style={{ padding: '0 24px 24px' }}>
                        <Content
                        className="site-layout-background"
                        style={{
                            padding: 24,
                            margin: 0,
                            minHeight: 280,
                        }}
                        >
                            {renderRoutes(this.props.route.routes)}
                        </Content>
                    </Layout>
                </Layout>
            </Layout>
        )
    }
}

let stateMapToProps = (state) => {
    return state
}

export default connect(stateMapToProps)(Main);
